/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "client")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Client.findAll", query = "SELECT c FROM Client c"),
    @NamedQuery(name = "Client.findByClientId", query = "SELECT c FROM Client c WHERE c.clientId = :clientId"),
    @NamedQuery(name = "Client.findByClientType", query = "SELECT c FROM Client c WHERE c.clientType = :clientType"),
    @NamedQuery(name = "Client.findByPharmacyIdByClientTypeByActive", query = "SELECT c FROM Client c WHERE c.pharmacyId.pharmacyId = :pharmacyId AND c.clientType = :clientType AND c.active = :active"),
    @NamedQuery(name = "Client.findByName", query = "SELECT c FROM Client c WHERE c.name = :name"),
    @NamedQuery(name = "Client.findByPharmacyIdByNameByActive", query = "SELECT c FROM Client c WHERE c.pharmacyId.pharmacyId = :pharmacyId AND c.name like :name AND c.active = :active"),
    @NamedQuery(name = "Client.findBySocialReason", query = "SELECT c FROM Client c WHERE c.socialReason = :socialReason"),
    @NamedQuery(name = "Client.findByNit", query = "SELECT c FROM Client c WHERE c.nit = :nit"),
    @NamedQuery(name = "Client.findByNitByActive", query = "SELECT c FROM Client c WHERE c.nit = :nit AND c.active = :active"),
    @NamedQuery(name = "Client.findByPharmacyIdByNitByActive", query = "SELECT c FROM Client c WHERE c.pharmacyId.pharmacyId = :pharmacyId AND c.nit like :nit AND c.active = :active"),
    @NamedQuery(name = "Client.findByBirthdate", query = "SELECT c FROM Client c WHERE c.birthdate = :birthdate"),
    @NamedQuery(name = "Client.findByLastName", query = "SELECT c FROM Client c WHERE c.lastName = :lastName"),
    @NamedQuery(name = "Client.findByLastName2", query = "SELECT c FROM Client c WHERE c.lastName2 = :lastName2"),
    @NamedQuery(name = "Client.findByPhone", query = "SELECT c FROM Client c WHERE c.phone = :phone"),
    @NamedQuery(name = "Client.findByCellphone", query = "SELECT c FROM Client c WHERE c.cellphone = :cellphone"),
    @NamedQuery(name = "Client.findByEmail", query = "SELECT c FROM Client c WHERE c.email = :email"),
    @NamedQuery(name = "Client.findByEmail2", query = "SELECT c FROM Client c WHERE c.email2 = :email2"),
    @NamedQuery(name = "Client.findByAddress", query = "SELECT c FROM Client c WHERE c.address = :address"),
    @NamedQuery(name = "Client.findByFax", query = "SELECT c FROM Client c WHERE c.fax = :fax"),
    @NamedQuery(name = "Client.findByPhoto", query = "SELECT c FROM Client c WHERE c.photo = :photo"),
    @NamedQuery(name = "Client.findByPharmacyIdByActive", query = "SELECT c FROM Client c WHERE c.pharmacyId.pharmacyId = :pharmacyId AND c.active = :active"),
    @NamedQuery(name = "Client.findByActive", query = "SELECT c FROM Client c WHERE c.active = :active")})
public class Client implements Serializable {
    private static final long serialVersionUID = 1L;
    /*
    @Id
    @Basic(optional = false)
    @Column(name = "clientId")*/
    @Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer clientId;
    @Basic(optional = false)
    @Column(name = "clientType")
    private String clientType;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Column(name = "socialReason")
    private String socialReason;
    @Column(name = "nit")
    private String nit;
    @Column(name = "birthdate")
    @Temporal(TemporalType.DATE)
    private Date birthdate;
    @Column(name = "lastName")
    private String lastName;
    @Column(name = "lastName2")
    private String lastName2;
    @Column(name = "phone")
    private String phone;
    @Column(name = "cellphone")
    private String cellphone;
    @Column(name = "email")
    private String email;
    @Column(name = "email2")
    private String email2;
    @Column(name = "address")
    private String address;
    @Column(name = "fax")
    private String fax;
    @Column(name = "photo")
    private String photo;
    @Basic(optional = false)
    @Column(name = "active")
    private boolean active;
    @JoinColumn(name = "pharmacyId", referencedColumnName = "pharmacyId")
    @ManyToOne(optional = false)
    private Pharmacy pharmacyId;
    @OneToMany(mappedBy = "clientId")
    private Collection<Transaction> transactionCollection;
    @OneToMany(mappedBy = "clientId")
    private Collection<Accountreceivable> accountreceivableCollection;
    @OneToMany(mappedBy = "clientId")
    private Collection<Contactperson> contactpersonCollection;

    public Client() {
    }

    public Client(Integer clientId) {
        this.clientId = clientId;
    }

    public Client(Integer clientId, String clientType, String name, boolean active) {
        this.clientId = clientId;
        this.clientType = clientType;
        this.name = name;
        this.active = active;
    }

    public Integer getClientId() {
        return clientId;
    }

    public void setClientId(Integer clientId) {
        this.clientId = clientId;
    }

    public String getClientType() {
        return clientType;
    }

    public void setClientType(String clientType) {
        this.clientType = clientType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSocialReason() {
        return socialReason;
    }

    public void setSocialReason(String socialReason) {
        this.socialReason = socialReason;
    }

    public String getNit() {
        return nit;
    }

    public void setNit(String nit) {
        this.nit = nit;
    }

    public Date getBirthdate() {
        return birthdate;
    }

    public void setBirthdate(Date birthdate) {
        this.birthdate = birthdate;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getLastName2() {
        return lastName2;
    }

    public void setLastName2(String lastName2) {
        this.lastName2 = lastName2;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCellphone() {
        return cellphone;
    }

    public void setCellphone(String cellphone) {
        this.cellphone = cellphone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getEmail2() {
        return email2;
    }

    public void setEmail2(String email2) {
        this.email2 = email2;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    public boolean getActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public Pharmacy getPharmacyId() {
        return pharmacyId;
    }

    public void setPharmacyId(Pharmacy pharmacyId) {
        this.pharmacyId = pharmacyId;
    }

    @XmlTransient
    public Collection<Transaction> getTransactionCollection() {
        return transactionCollection;
    }

    public void setTransactionCollection(Collection<Transaction> transactionCollection) {
        this.transactionCollection = transactionCollection;
    }

    @XmlTransient
    public Collection<Accountreceivable> getAccountreceivableCollection() {
        return accountreceivableCollection;
    }

    public void setAccountreceivableCollection(Collection<Accountreceivable> accountreceivableCollection) {
        this.accountreceivableCollection = accountreceivableCollection;
    }

    @XmlTransient
    public Collection<Contactperson> getContactpersonCollection() {
        return contactpersonCollection;
    }

    public void setContactpersonCollection(Collection<Contactperson> contactpersonCollection) {
        this.contactpersonCollection = contactpersonCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (clientId != null ? clientId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Client)) {
            return false;
        }
        Client other = (Client) object;
        if ((this.clientId == null && other.clientId != null) || (this.clientId != null && !this.clientId.equals(other.clientId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Client[ clientId=" + clientId + " ]";
    }
    
}
